package com.lzp.wechat.controller;

import com.lzp.wechat.service.QrCodeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;

@RestController
@Api(tags = "二维码接口")
public class QrCodeController {

    @Autowired
    private QrCodeService qrCodeService;

    @PostMapping("/qrcode/create")
    @ApiOperation(value = "生成二维码", notes = "临时二维码&永久二维码")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "action_name", value = "二维码类型", required = true, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "scene_id", value = "场景值ID", required = false, dataType = "Integer"),
            @ApiImplicitParam(paramType = "query", name = "scene_str", value = "场景值ID（字符串形式的ID）", required = false, dataType = "String")
    })
    public void createQrCode(@RequestParam("action_name") String action_name,
                             @RequestParam(value = "scene_id", required = false) Integer scene_id,
                             @RequestParam(value = "scene_str", required = false) String scene_str,
                             HttpServletResponse response) {
        qrCodeService.createQrCode(action_name, scene_id, scene_str, response);
    }

}
